package pers.litao.bit.commons.validator.constraint;

import cn.hutool.core.util.StrUtil;
import pers.litao.bit.commons.validator.annotation.PasswordValid;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author 李涛
 * @date 2020-11-15 15:44
 */
public class PasswordConstraintValidator implements ConstraintValidator<PasswordValid,String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if(StrUtil.isNotBlank(value)){
            return false;
        }
        return value.length() >= 6 && value.length() <= 16 && !value.contains(" ");
    }

}
